require 'nokogiri'
require 'metainspector'
require 'rspec'
require 'hpricot'
require 'open-uri'

url="http://www.nbnco.com.au/nbn-for-business/index.html"
doc_for_title =Hpricot(open(url))
title=(doc_for_title/"title").inner_text

file = open (url) # open url as file stream
doc = Nokogiri::XML(file)
meta_array = []


doc.xpath("//meta").each do |meta_item|


meta_array.push  ({name: meta_item.attribute('name'),
		   scheme: meta_item.attribute('scheme'),	
		   content: meta_item.attribute('content')}) if meta_item.has_attribute?("name")


end

meta_array.each do |meta_ele|

case meta_ele[:name].to_s
	when "DCTERMS.creator"
	meta_ele[:content].to_s.should == "NBN Co Limited"
	when "DCTERMS.title"
	meta_ele[:content].to_s.should == title 
	when "DCTERMS.publisher"
	meta_ele[:content].to_s.should == "NBN Co Limited"
	when "AGLSTERMS.category"
	meta_ele[:content].to_s.should == "document"	
	when "AGLSTERMS.aggregationLevel"
	meta_ele[:content].to_s.should == "item"
	when "DCTERMS.rights"	
	meta_ele[:content].to_s.should == "Copyright NBN Co Limited 2012"
	when "DCTERMS.format"
	meta_ele[:content].to_s.should == "text/html"	
end
puts "#{meta_ele[:name]} is #{meta_ele[:content]}"
end



